package thread.oom;

import serializabale.Person;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: ch-general
 * @description:
 * @author: cuihao
 * @create: 2020-04-17 19:10
 **/
public class JvmThread {

    public static void main(String[] args) {

//        new Thread() {
////            @Override
////            public void run() {
////                List<byte[]> list = new ArrayList<>();
////                while (true) {
////                    // 1M
////                    byte[] bytes = new byte[1024 * 1024];
////                    list.add(bytes);
////                    System.out.println(Thread.currentThread().getName());
////                    try {
////                        Thread.sleep(100);
////                    } catch (InterruptedException e) {
////                        System.out.println("sleep");
////                    }
////                }
////            }
////        }.start();

        new Thread() {
            @Override
            public void run() {
                List<Person> list = new ArrayList<>();
                while (true) {
                    Person person = new Person();
                    person.setName("nameA");
                    person.setAddress("addressA");
                    list.add(person);
                    System.out.println(Thread.currentThread().getName());
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        System.out.println("sleep");
//                    }
                }
            }
        }.start();
    }
}
